package com.fenghongzhang.shop1903;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.fenghongzhang.shop1903.databinding.ActivityMainBinding;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_main);

        ActivityMainBinding activityMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);

//        User user = new User("大明", 10);

//        activityMainBinding.setUser(user);
//        activityMainBinding.setMain(this);


        RecyclerView rv = findViewById(R.id.rv);
        rv.setLayoutManager(new LinearLayoutManager(this));
        List<User> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(new User("大明"+i, 10,"http://www.qubaobei.com/ios/cf/uploadfile/132/9/8289.jpg"));

        }
        MyAdapter myAdapter = new MyAdapter(list);

        rv.setAdapter(myAdapter);

    }

    @Override
    public void onClick(View v) {
        Toast.makeText(this, "哈哈哈", Toast.LENGTH_SHORT).show();
    }


}
